import request from "@/utils/request";
import type { addStuResponseData, deleteStuResponseData, pageData, pageStuResponseData, studentInfoData, studentYearResponseData } from "./type";

//@ts-ignore
enum API{
    ADD_STU = "/manage/student/add",
    FIND_BY_ID = "/manage/student/find",
    UPDATE_STU = "/manage/student/update",
    PAGE_STU = "/manage/student/list",
    DELETE_STU = "/manage/student/delete",
    STUDENT_MONTH_DATA_URL = "manage/student/date"
}

//添加学员
export const reqAddStu = (data:studentInfoData)=>request.post<any,addStuResponseData>(API.ADD_STU,data);
//根据id查询学员
export const reqFindById = (_id:string)=>request.get<any,addStuResponseData>(API.FIND_BY_ID+`?_id=${_id}`);
//更新学员信息
export const reqUpdateStu = (data:studentInfoData)=>request.post<any,addStuResponseData>(API.UPDATE_STU,data);
//获取学员列表（分页）
export const reqPageStu = (data:pageData)=>request.post<any,pageStuResponseData>(API.PAGE_STU,data);
//删除学员
export const reqDeleteStu = (studentId:string)=>request.post<any,deleteStuResponseData>(API.DELETE_STU,{studentId})

//查询某某一年每月学员数量
export const reqStudentsForYear = (year:number)=>request.post<any,studentYearResponseData>(API.STUDENT_MONTH_DATA_URL,{year});